//
//  RegistViewController.m
//  qiuShiJiangHu
//
//  Created by xalo on 16/1/25.
//  Copyright © 2016年 糗事江湖项目组. All rights reserved.
//

#import "RegistViewController.h"
#import "FMDB/FMDB.h"
@interface RegistViewController ()<UITextFieldDelegate>

@end

@implementation RegistViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self keyboardReturn];
    [self setRegistViewInfo];
//        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"登录" style:(UIBarButtonItemStyle) target:self action:@selector(leftButtonAction)];
    
    
    // Do any additional setup after loading the view.
}

- (void)setRegistViewInfo {
    
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"loginBack.jpg"]];
    [self.registButton.layer setMasksToBounds:YES];
    [self.registButton.layer setCornerRadius:10.0];
    self.registButton.backgroundColor = [UIColor orangeColor];
    
}


- (void)keyboardReturn {
    
    self.userNameRTF.delegate = self;
    self.passWordRTF.delegate = self;
    self.againPassWprdRTF.delegate = self;
    self.phoneNumberRTF.delegate = self;

    
}


- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    
    
    [textField resignFirstResponder];
    return YES;
    
}

//注册判断
- (IBAction)regist:(UIButton *)sender {
    
    if ([self.userNameRTF.text isEqualToString:@""] || [self.passWordRTF.text isEqualToString:@""]) {
        
        
        [self setAlertWithTitle:@"温馨提示" withMessage:@"用户名或密码不能为空"];
        
    }else if (![self.passWordRTF.text isEqualToString:self.againPassWprdRTF.text]){
        
        [self setAlertWithTitle:@"温馨提示" withMessage:@"密码不一致"];
        
    }else{
        
        
        
        
    }
    
    
    
}

//封装设置alert方法
- (void)setAlertWithTitle:(NSString *)title withMessage:(NSString *)message {
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:nil];
    [alert addAction:okAction];
    alert.view.tintColor = [UIColor orangeColor];
    [self presentViewController:alert animated:YES completion:nil];
    
}

//创建数据库
















- (void)setSqlite {
    
    NSString *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
    
    NSString *dbPath = [documentPath stringByAppendingPathComponent:@"db.sqlite"];
    FMDatabase *db = [FMDatabase databaseWithPath:dbPath];
    //打开数据库
    [db open];
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
